package com.gigi.controller;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.gigi.entity.TagShiqinEntity;
import com.gigi.model.IdRequest;
import com.gigi.model.ListRequest;
import com.gigi.model.TypeTagDO;
import com.gigi.service.manual.TagManageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 标签管理
 */
@RestController
@RequestMapping("tag-manage")
public class TagManageController {

    private final TagManageService tagManageService;

    public TagManageController(TagManageService tagManageService) {
        this.tagManageService = tagManageService;
    }

    @ApiOperation(value = "列表")
    @PostMapping("/list")
    public MultiResponse<TagShiqinEntity> list(@RequestBody ListRequest request) {
        return tagManageService.list(request);
    }

    @ApiOperation(value = "详情")
    @PostMapping("/detail")
    public SingleResponse<TagShiqinEntity> detail(@RequestBody @Valid IdRequest request) {
        return tagManageService.detail(request.getId());
    }

    @ApiOperation(value = "保存")
    @PostMapping("/save")
    public Response save(@RequestBody @Valid TypeTagDO request) {
        return tagManageService.save(request);
    }

    @ApiOperation(value = "删除")
    @PostMapping("/delete")
    public Response delete(@RequestBody @Valid IdRequest request) {
        return tagManageService.delete(request.getId());
    }

}
